inline getprogname replacement
authorMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 Jan 2026 19:27:54 +0000 (22:27 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 17 Apr 2026 08:02:47 +0000 (11:02 +0300)
Forwarded: not-needed

Inline getprogname() by using program_invocation_short_name
when available (like with glibc).

This makes a lot of binaries to avoid linkage to libreplace.

This is a short and dirty version, proper change for upstream
should clean up #ifdef'fery in replace.c.

Gbp-Pq: Name inline-getprogname.diff

lib/replace/replace.c
lib/replace/replace.h

index 33cbbec14533dd11e81bceaf6a7e5450d1118cab..b0e1edbdf21f091f7b6f33e639e596deedf26e7c 100644 (file)
@@ -1144,7 +1144,7 @@ void *rep_memset_explicit(void *block, int c, size_t size)
 }
 #endif
 
-#ifndef HAVE_GETPROGNAME
+#if !defined(HAVE_GETPROGNAME) && !defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
 # ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
 # define PROGNAME_SIZE 32
 static char rep_progname[PROGNAME_SIZE];
index da5cc5be072574d6d29dfbd03e4115b0ba9879d1..9d75ceae76e89ffc26ea37e67ba2f65a481cd94a 100644 (file)
@@ -1012,9 +1012,13 @@ void *rep_memset_explicit(void *block, int c, size_t size);
 #endif
 
 #ifndef HAVE_GETPROGNAME
+#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+# define getprogname() (program_invocation_short_name)
+#else
 #define getprogname rep_getprogname
 const char *rep_getprogname(void);
 #endif
+#endif
 
 #ifndef HAVE_COPY_FILE_RANGE
 #define copy_file_range rep_copy_file_range